/*
 * Copyright 2007-2009 Thomas Krause (thomas@berlin-reloaded.de)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.gidoo.websites.example;

import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.gidoo.cms.DefaultConfiguration;
import org.gidoo.cms.GidooCMS;
import org.gidoo.cms.IAdminPlugin;
import org.gidoo.cms.IEditPlugin;
import org.gidoo.cms.IPlugin;
import org.gidoo.cms.editor.edit.EditorComponent;
import org.gidoo.cms.eventhandler.CMSEventListener;
import org.gidoo.cms.eventhandler.OnPublishPageEvent;
import org.gidoo.cms.extra.wymeditor.WYMEditorComponent;
import org.gidoo.cms.view.ContentView;
import org.gidoo.websites.example.plugins.TestAdminPlugin;
import org.gidoo.websites.example.plugins.TestEditingPlugin;
import org.gidoo.websites.example.plugins.TestPublishingPlugin;

/**
 * This is the main class. 
 * @author <a href="mailto:thomas@berlin-reloaded.de">Thomas Krause</a>
 */
public class App extends GidooCMS
{

  @Override
  public String getConfigurationType()
  {
    return DEPLOYMENT;
  }

  @Override
  public DefaultConfiguration createNewConfiguration()
  {
    return new DefaultConfiguration()
    {

      @Override
      public Class<? extends ContentView> getCMSMainPage()
      {
        return View.class;
      }

      

      @Override
      public Class<? extends ContentView> getCMSPreviewPage()
      {
        return Preview.class;
      }



      @Override
      public List<IPlugin> getPublishPlugins()
      {
        List<IPlugin> list = new ArrayList<IPlugin>();
        list.add(new TestPublishingPlugin());
        return list;
      }

      @Override
      public List<IEditPlugin> getEditPlugins()
      {
        List<IEditPlugin> list = new ArrayList<IEditPlugin>();
        list.add(new TestEditingPlugin());
        return list;
      }

      @Override
      public List<IAdminPlugin> getAdminPlugins()
      {
        List<IAdminPlugin> list = new ArrayList<IAdminPlugin>();
        list.add(new TestAdminPlugin());
        return list;
      }

      @Override
      public Class<? extends EditorComponent> getEditorComponent()
      {
        return WYMEditorComponent.class;
      }
    };
  }

  @Override
  protected void init()
  {
    super.init();

    getEventManager().addListener(new CMSEventListener<OnPublishPageEvent>()
    {

      @Override
      public void handleEvent(OnPublishPageEvent event)
      {
        Logger.getAnonymousLogger().log(Level.INFO, "page published: " + event.getAbsoluteNodePath());
      }

    });

  }
}

